package demo3;

public class Text04 {
    public static void main(String[] args) {
        Student s1 = Student.crateStudentByAgeAndName(18, "张三");
        Student s2 = Student.crateStudentByClassIdAndName(1, "李四");
    }
}

/**
 * 定义一个Student类
 */
class Student {
    private int id;
    private int age;
    private int classId;
    private String name;
    private String sno;

    public Student() {
    }

//    // 通过age和name初始化一个对象
//    public Student (int age, String name) {
//        this.age = age;
//        this.name = name;
//    }
//
//    // 通过classId和name初始化一个对象
//    public Student (int classId, String name) {
//        this.classId = classId;
//        this.name = name;
//    }

    // 通过age和name初始化一个对象
    public static Student crateStudentByAgeAndName (int age, String name) {
        Student student = new Student();
        student.setAge(age);
        student.setName(name);
        return student;
    }

    // 通过classId和name初始化一个对象
    public static Student crateStudentByClassIdAndName (int classId, String name) {
        Student student = new Student();
        student.setClassId(classId);
        student.setName(name);
        return student;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getClassId() {
        return classId;
    }

    public void setClassId(int classId) {
        this.classId = classId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSno() {
        return sno;
    }

    public void setSno(String sno) {
        this.sno = sno;
    }
}